# 添加，修改，查询 接口对象层
import requests


# 定义类


class Supcon_Api():

    # 定义添加人员方法
    @classmethod
    def add(cls, jsondata, header):
        req = requests.post(url="http://60.170.204.207:35791/inter-api/organization/v1/person", headers=header,
                            json=jsondata)

        return req

    # 定义查询人员方法
    @classmethod
    def query(cls, header, id):
        req = requests.get(
            url="http://60.170.204.207:35791/inter-api/organization/v1/person/modify/page?personId=" + id,
            headers=header)

        return req

    # 定义修改人员方法
    @classmethod
    def modify(cls, header, id, name_json):
        req = requests.put(
            url="http://60.170.204.207:35791/inter-api/organization/v1/person/modify/page?personId=" + id,
            headers=header, json=name_json)

        return req

    # 定义删除人员方法
    @classmethod
    def dele(cls, header, id):
        req = requests.delete(
            url="http://60.170.204.207:35791/inter-api/organization/v1/person/modify/page?personId=" + id,
            headers=header)

        return req


if __name__ == '__main__':
    header = {"ticket": "KU3z416vxgNsVvmoEU-M-"}
    jsondata = {"name": "徐媛", "code": "3009", "gender": "sys_gender/female", "status": "sys_person_status/onWork",
                "mainPosition": 4055449048285056}
    name_json = {"name": "张三"}

    response = Supcon_Api.add(jsondata, header)
    print("添加员工:", response.json())

    id = "5171645435445120"
# reponse = Supcon_Api.dele(header, id)

# print("删除员工:", reponse.json())
